package peer.model.transfer;

import java.io.File;
import java.net.Socket;
import java.util.ArrayList;

import model.dto.FileDTO;
import model.dto.UserDTO;
import peer.model.consts.TransferConsts;
import peer.model.transfer.file.FileSender;
import peer.model.transfer.runnable.FileDownloadInstance;

public class TransfersManager {

	public static FileDownloadInstance createNewFileDownloadInstance(ArrayList<UserDTO> peers, FileDTO requestedFile){
		FileDownloadInstance newInstance=new FileDownloadInstance(peers, requestedFile);
		new Thread(newInstance).start();
		return newInstance;
	}

	public static void startUpload(Socket cnxHost, String fileName/*se van a pedir metadata o bloques por este param*/){
		System.out.println("[PEER/UPLOAD] Connected");
		//sendBlock....
		//sendFileName
		//sendSize
		//segun corresponda
		FileSender.sendFile(cnxHost, new File( TransferConsts.FILESERVE_PATH+ "/" + fileName));
		System.out.println("[PEER/UPLOAD] File Sent.");
	}

}
